//
// Created by ziya on 22-6-26.
//

#ifndef ZIYA_OSKERNEL_TEACH_TYPES_H
#define ZIYA_OSKERNEL_TEACH_TYPES_H

#define EOF -1 // END OF FILE

#define NULL ((void *)0) // 空指针

#define EOS '\0' // 字符串结尾

#define bool _Bool
#define true 1
#define false 0

typedef unsigned int size_t;

typedef long long int64;

typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;

typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long u64;

#ifdef CONFIG_PHYS_ADDR_T_64BIT
typedef u64 phys_addr_t;
#else
typedef u32 phys_addr_t;
#endif

#define PAGE_SIZE 4096

#define max_t(type, x, y) ({\
    type __max1 = (x); \
    type __max2 = (y); \
    __max1 > __max2 ? __max1 : __max2; \
})

#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y))

#define clamp(val, lo, hi) min((typeof(val)) max(val, lo), hi)

#define __round_mask(x, y) ((__typeof__(x))((y) - 1))

#define round_up(x, y) ((((x) - 1) | __round_mask(x, y)) + 1)

#define round_down(x, y) ((x) & ~__round_mask(x, y))

#endif //ZIYA_OSKERNEL_TEACH_TYPES_H
